﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.ComponentModel;
using System.Configuration;
using System.IO;
using System.Windows.Forms;

using LibSnesDotNet.Core;
using LibSnesDotNet.UI;
using LibSnesDotNet.Input;

namespace LibSnesDotNet
{
	public class Program
	{
		[STAThread]
		static void Main(string[] args)
		{
			var configMap = new ExeConfigurationFileMap();
			configMap.ExeConfigFilename = Application.ExecutablePath + ".config";
			configMap.RoamingUserConfigFilename = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
			                                                   "LibSnesDotNet",
			                                                   "LibSnesDotNet.config");

			Configuration config = new Configuration(configMap);

			Application.EnableVisualStyles();
			Application.ThreadException += (s, e) =>
			{
				MessageBox.Show(e.Exception.ToString(), "Unhandled Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
				Environment.Exit(-1);
			};
			Application.Run(new MainForm(config));

			config.Save();
		}
	}
}
